<%@page import="java.sql.Timestamp"%>
<%@page import="java.util.List"%>
<%@page import="com.metacube.questionbank.model.Question"%>
<%@page import="com.metacube.questionbank.model.Tag"%>
<%@page import="com.metacube.questionbank.model.User"%>
<div class="container questions" id="question_list">
	<% List<Question> questions = (List<Question>) request.getAttribute("questions");%>
	<% List<List<Tag>> tags = (List<List<Tag>>) request.getAttribute("tags");%>
	<% List<Integer> ansCount = (List<Integer>) request.getAttribute("ansCount");%>
	<% List<User> userList = (List<User>) request.getAttribute("userList");%>
	<h4>Questions</h4>
	<hr>
	<div id="questionLists" class="jplist clearfix">
		<div class="jplist-panel panel-top page-panel clearfix">
			<div class="jplist-label" data-type="Page {current} of {pages}"
				data-control-type="pagination-info" data-control-name="paging"
				data-control-action="paging">
			</div>
			<div class="jplist-pagination" data-control-type="pagination"
				data-control-name="paging" data-control-action="paging"
				data-items-per-page="5">
			</div>
		</div>
		<div class="list text-shadow">
			<% for (int qCounter=0;qCounter<questions.size();qCounter++)
			{
				Question q=questions.get(qCounter);
				int count=ansCount.get(qCounter);
				List<Tag> tagInQuestion=tags.get(qCounter);
			%>
			<div class="list-item question-summary clearfix">
				<div class="col-md-1 no_of_answers">
					<div class="count">
						<span title="answers"><%out.print(count);%></span>
					</div>
					<div >answers</div>
				</div>
				<div class="col-md-11">
					<h3><a href="QuestionAnswer.htm?id=<%=q.getQuesId()%>" title="question">	<%
					out.print(q.getQuestionTitle());
				%></a></h3>
					<div class="tags_posted clearfix">
						<div class="pull-left question_tags">
							<%for(int tagCounter=0;tagCounter<tagInQuestion.size();tagCounter++){ %>
							<a href="tag_questions.htm?id=<%=tagInQuestion.get(tagCounter).getTagId()%>"><%out.print(tagInQuestion.get(tagCounter).getTagName()); %></a>
							<%} %>
						</div>
						<div class="pull-right">
							<div>
							<span class="glyphicon glyphicon-time"></span>
							<label><%
								Timestamp queTime=q.getQuestionDate();
								out.print(queTime.getDate()+"-"+(queTime.getMonth()+1)+"-"+(queTime.getYear()+1900) +" "+queTime.getHours()+":"+queTime.getMinutes());%>
							</label>
							</div>
							<div>
							<a href="ReadByOthersprofile.htm?id=<%=userList.get(qCounter).getUser_id()%>"><%out.print(userList.get(qCounter).getName());%></a>
							<span>Rank: </span>
							<span> <%out.print(userList.get(qCounter).getRating());%></span>
							</div>
						</div>
					</div>
				</div>
			</div>
			<%} %>
		</div>
		<div class="jplist-no-results no-result text-shadow align-center">
				<p>No results found</p>
			</div>
			<!-- panel -->
			<div class="jplist-panel panel-bottom clearfix">
				
				<div 
				   class="jplist-label" 
				   data-type="{start} - {end} of {all}"
				   data-control-type="pagination-info" 
				   data-control-name="paging" 
				   data-control-action="paging">
				</div>
				
				<div 
				   class="jplist-pagination" 
				   data-control-type="pagination" 
				   data-control-name="paging" 
				   data-control-action="paging"
				   data-items-per-page="5">
				</div>
				
			</div>
	</div>	
</div>
<script>
	$('document').ready(function() {

		$('#questionLists').jplist({
			itemsBox : '.list',
			itemPath : '.list-item',
			panelPath : '.jplist-panel'
		});
	});
</script>